package com.codefish.framework.spring.beans.factory;

import com.codefish.framework.spring.beans.exception.NoSuchBeanDefinitionException;

/**
 * BeanFactory接口，作用是可以访问所有的Bean实例
 *
 * @author <a href='https://gitee.com/hzf2281'>codefish</a>
 * @version 1.0.0
 * @since 2022/09/23 下午 03:48
 */
public interface IBeanFactory {
    String FACTORY_BEAN_PREFIX = "&";

    /**
     * 获取bean对象
     * @param beanName beanName
     * @return beanName对应的bean对象
     * @throws NoSuchBeanDefinitionException 找不到bean时抛出
     */
    Object getBean(String beanName) throws NoSuchBeanDefinitionException;

    /**
     * 获取bean对象
     * @param beanName beanName
     * @param requiredType bean的类型
     * @param <T>  bean的类型
     * @return 指定beanName和类型的bean对象
     * @throws NoSuchBeanDefinitionException 找不到或类型不匹配时抛出
     */
    <T> T getBean(String beanName, Class<T> requiredType) throws NoSuchBeanDefinitionException;
}
